module.exports = function($scope, $modalInstance, $resource, obj, $modal, $state){
	console.log(obj);
	$scope.obj = obj;

	$scope.cancel = function(){

		$modalInstance.close();

	}

	$scope.gogo = function(){

		$resource('/api/as/wc/product/update', {}, {}).save($scope.obj, function (res) {
			console.log(res);

			if (res.errcode !== 0) {
				alert(res.errmsg);
				return;
			}
			alert("保存成功");
			$modalInstance.close();

		});

	}



	$scope.hengtu = function () {
		var para = $state.get('app.imageupload');
		para.resolve.dir = function(){
            return 'weshop_hengtu';
        };
        para.resolve.xxx = function(){
        	return {
        		'queueLimit' : 1,
        	};
        };
        var modalInstance = $modal.open(para);
        modalInstance.opened.then(function() {// 模态窗口打开之后执行的函数  
        });  
        modalInstance.result.then(function(result) {  
        	console.log(result);
        	if(result.length > 0){
        		console.log($scope.obj);
        		$scope.obj['img'] = result[0];
        	}
        	console.log($scope.obj);
        }, function(reason) {  
            // click，点击取消，则会暑促cancel  
            $log.info('Modal dismissed at: ' + new Date());  
        }); 

	}



};